﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CachingProject
{
    public class Set
    {
        public Block[] blocks;
        int numBlocks;
        int blockSize;

        public Set(int numB, int bSize)
        {
            numBlocks = numB;
            blockSize = bSize;
            blocks = new Block[numBlocks];
        }
        //addy = address, B = which block to search, W = which word in block to search
        public bool Search(int addy, int B, int W)
        {
            bool found;
            found = blocks[B].Search(addy, W); //call the Search on the block address would be in
            return found;
        }
        public void Load(int addy, int B, int W) //load a new block into the set on a miss
        {
            blocks[B] = new Block(addy, blockSize, W); //create a new block with the address in the proper word
        }
        public void Accessed(int B)
        {
            blocks[B].Accessed = 1; //increments accessed variable in the block B
        }
        public int GetAccessed(int B) //return the accessed variable in the block B
        {
            int ret;
            ret = blocks[B].Accessed;
            return ret;
        }
        public void ResetAccessed(int B) //reset the accessed variable in block B to 0.
        {
            blocks[B].ResetAccess();
        }
//-----------------------------------------------------------------------------
    }
}